package com.xuzong.controller;

import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
import com.xuzong.pojo.TbArea;
import com.xuzong.service.TbAreaService;
import com.xuzong.uilts.FreemarkerUtil;
import com.xuzong.util.R;
import freemarker.template.TemplateException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping("/warehouse/area")
public class TbAreaController {



    @Autowired
    TbAreaService tbAreaService;

    /**
     * @description: 三级联动
     * @author: xushuaihang
     * @Date: 2024/8/3 9:56
     * @param:
     * @return: com.xuzong.util.R
    **/
    @RequestMapping("/areaList")
    public R areaList(){
        return tbAreaService.areaList();
    }

    @RequestMapping("/staticMy")
    public R staticMy() throws TemplateException, IOException {
        FreemarkerUtil freemarkerUtil = new FreemarkerUtil();

        HashMap<String, Object> map = new HashMap<>();

        List<TbArea> list = tbAreaService.list();

        TbArea tbArea = list.get(0);

        map.put("list",tbArea);

        String url = "D:\\"+ UUID.randomUUID().toString()+".html";

        freemarkerUtil.createHtml(map,"staticMy",url);

        return R.ok();
    }
    @RequestMapping("/list")
    public R list(){
        List<TbArea> list = tbAreaService.list();

        return R.ok();
    }
    @RequestMapping("/test")
    public void  test1(){
        System.out.println("!11111");
    }

    public static void main(String[] args) {
        System.out.println("我是李沁 哈哈哈哈");
        System.out.println("我是李沁 哈哈哈哈");
        System.out.println("我是李沁 哈哈哈哈");
    }




}
